<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
  <meta name="keywords" content="逗逼联盟,逗逼阅读,无广告,小说" th:content="${systemInfo.metaKeywords}" />
  <meta name="description" content="做最简洁，最干净的小说聚合网站" th:content="${systemInfo.metaDescription}" />
  <title th:text="${systemInfo.sitename}+'-顶部导航'">顶部导航栏</title>
  <link rel="stylesheet" th:href="@{/css/home.css}" href="../../static//css/home.css">
  <link rel="stylesheet" th:href="@{/css/custom_theme.css}" href="../../static/css/custom_theme.css">
  <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" href="../../static/lib/layui/css/layui.css">
  <script th:fragment="StatisticsJs">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b486f018abfcfa6d9b99f75f37cf0852";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>
</head>
<body class="theme-0">

<div class="layui-row novel-header" th:fragment="header">
  <div class="header-item layui-col-xs8 layui-col-md8 layui-col-md-offset1">
    <a href="../index.html" th:href="@{/index}">
      <img src="../../static/imgs/icon/logo.png" th:src="@{/imgs/icon/logo.png}" class="header-logo">
      <span class="title" th:text="${systemInfo.sitename}">逗逼联盟-逗逼阅读</span>
    </a>
    <span class="tips layui-hide-xs" th:text="${systemInfo.metaDescription}">做最简洁，最干净的小说聚合网站</span>
    <a href="/donate/list" class="tips layui-hide-xs" style="text-decoration: underline;font-size: 16px;">捐赠榜单</a>
    <span class="tips layui-hide-xs " id="donate" style="color: red;font-size: 20px;cursor: pointer;">捐赠</span>
  </div>

  <div class="header-item layui-col-xs4 layui-col-md3 layui-row">
    <form th:action="@{/search}" action="/search" method="post" id="form">
      <div class="layui-col-xs9 layui-col-md7 header-search layui-hide-xs">
        <input id="name" class="layui-input" type="text" name="name" required lay-verify="required" placeholder="请输入书名或作者名">
      </div>
      <div class="layui-col-xs3 layui-col-md2 header-search layui-hide-xs">
        <i class="layui-icon" onclick="submit()">&#xe615;</i>
      </div>

      <div th:if="${user == null}" class="layui-col-md3 header-search">
        <button type="button" class="layui-btn layui-btn-normal layui-btn-sm " onclick="showLoginDialog()">登录</button>
        <a target="_blank" href="/register" class="layui-btn layui-btn-primary layui-btn-sm ">注册</a>
      </div>

      <div th:if="${user != null}" class="layui-col-md3 header-search layui-hide-xs">
        <ul class="layui-nav layui-layout-right" style="background-color: rgba(237,231,218,0.7)">
          <li class="layui-nav-item layuimini-setting">
            <a href="javascript:;" th:text="${user.name}" style="color: rgba(0,0,0,0.7);overflow: hidden;white-space: nowrap;text-overflow: ellipsis">admin</a>
            <dl class="layui-nav-child">
              <dd>
                <a href="/bookshelf/index" class="book-shelf">我的书架</a>
              </dd>
              <dd>
                <a href="#" class="user-center">个人中心</a>
              </dd>
              <dd>
                <a href="/logout" class="login-out">退出登录</a>
              </dd>
            </dl>
          </li>
        </ul>
      </div>

    </form>
  </div>

  <script>
    $.ajax({
      url: '/findNotification',
      method: 'get',
      dataType: 'json',
      success: function (rst) {
        if (rst.success) {
          var data = rst.data;
          var isShow = false;
          var lastReadId = localStorage.getItem('lastReadId');
          if (lastReadId == null || lastReadId == '' || lastReadId == undefined){
            isShow = true;
          }else {
            lastReadId = parseInt(lastReadId);
            if (lastReadId < data.id){
              isShow = true;
            }
          }
          if (isShow){
            var html =
                    '<div style="padding:15px 20px; text-align:justify; line-height: 22px;border-bottom:1px solid #e2e2e2;background-color: #2f4056;color: #ffffff">\n' +
                    '<div style="text-align: center;margin-bottom: 20px;font-weight: bold;border-bottom:1px solid #718fb5;padding-bottom: 5px"><h4 class="text-danger">' + data.title + '</h4></div>\n' +
                    '<div style="font-size: 12px">' + data.content + '</div>\n' +
                    '</div>\n';
            parent.layer.open({
              type: 1,
              title: '系统公告'+'<span style="float: right;right: 1px;font-size: 12px;color: #b1b3b9;margin-top: 1px">'+data.created+'</span>',
              area: '300px;',
              shade: 0.8,
              id: 'layuimini-notice',
              btn: ['确定'],
              btnAlign: 'c',
              moveType: 1,
              content:html,
              success: function (layero) {
                localStorage.setItem('lastReadId',data.id);
              }
            });
          }
        }
      },
      error: function (err) {
        layer.alert('网络异常，请稍后再试');
      }
    })
  </script>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
<script th:src="@{/js/home.js}" src="../../static/js/home.js"></script>
<script th:src="@{/lib/layui/layui.all.js}" src="../../static/lib/layui/layui.all.js"></script>
</body>
</html>